#import "BWGridWindowController.h"
#import "BWGraphDocument.h"

static BWGridWindowController *g_controller;


@implementation BWGridWindowController

- (void) setDocument: (NSDocument *) document
{
    [super setDocument: document];

    // update inspector
    [attributesController 
        setContent: [document valueForKey: @"gridAttributes"]];

    [fabricController 
        setContent: [document valueForKey: @"fabric"]];

    [gridController 
        setContent: [document valueForKey: @"controllingGeometry"]];

    if (document == nil) {
        [[self window] setTitle: @"Fabric Inspector"];
    }

} // setDocument


- (NSString *) windowTitleForDocumentDisplayName: (NSString *) displayName
{
    NSString *string;

    string = [NSString stringWithFormat: @"Fabric for %@", displayName];
    return (string);

} // windowTitleForDocumentDisplayName


+ (NSString *) autosaveName
{
    return (@"gridWindow");
} // autosaveName


+ (BWWindowController *) sharedInstance
{
    return (g_controller);
} // sharedInstance


+ (void) setSharedInstance: (BWWindowController *) controller
{
    assert ([[controller class] isSubclassOfClass: self]);

    g_controller = (BWGridWindowController *)controller;

} // setShraedInstance


+ (BWGridWindowController *) sharedController
{
    return ((BWGridWindowController*)[super sharedController]);
} // sharedController



+ (NSString *) windowNibName
{
    return (@"BWGridWindow");
} // windowNibName

@end // BWGridWindowController

